<!doctype html><html lang="en">
 <head>
  <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  <title>CSS Shadow Parts</title>
  <meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
  <meta content="exploring" name="csswg-work-status">
  <meta content="ED" name="w3c-status">
  <meta content="This specification defines the &apos;&apos;::part()&apos;&apos; pseudo-element on <a>shadow hosts</a>, allowing <a>shadow hosts</a> to selectively expose chosen elements from their <a>shadow tree</a> to the outside page for styling purposes." name="abstract">
  <link href="../default.css" rel="stylesheet" type="text/css">
  <link href="../csslogo.ico" rel="shortcut icon" type="image/x-icon">
<style>
  body {
    background: url("https://www.w3.org/StyleSheets/TR/logo-ED") top left no-repeat;
  }
  </style>
  <link href="https://www.w3.org/TR/css-shadow-parts-1/" rel="canonical">
<style>/* style-md-lists */

/* This is a weird hack for me not yet following the commonmark spec
   regarding paragraph and lists. */
[data-md] > :first-child {
    margin-top: 0;
}
[data-md] > :last-child {
    margin-bottom: 0;
}</style>
<style>/* style-selflinks */

.heading, .issue, .note, .example, li, dt {
    position: relative;
}
a.self-link {
    position: absolute;
    top: 0;
    left: calc(-1 * (3.5rem - 26px));
    width: calc(3.5rem - 26px);
    height: 2em;
    text-align: center;
    border: none;
    transition: opacity .2s;
    opacity: .5;
}
a.self-link:hover {
    opacity: 1;
}
.heading > a.self-link {
    font-size: 83%;
}
li > a.self-link {
    left: calc(-1 * (3.5rem - 26px) - 2em);
}
dfn > a.self-link {
    top: auto;
    left: auto;
    opacity: 0;
    width: 1.5em;
    height: 1.5em;
    background: gray;
    color: white;
    font-style: normal;
    transition: opacity .2s, background-color .2s, color .2s;
}
dfn:hover > a.self-link {
    opacity: 1;
}
dfn > a.self-link:hover {
    color: black;
}

a.self-link::before            { content: "¶"; }
.heading > a.self-link::before { content: "§"; }
dfn > a.self-link::before      { content: "#"; }</style>
<style>/* style-counters */

body {
    counter-reset: example figure issue;
}
.issue {
    counter-increment: issue;
}
.issue:not(.no-marker)::before {
    content: "Issue " counter(issue);
}

.example {
    counter-increment: example;
}
.example:not(.no-marker)::before {
    content: "Example " counter(example);
}
.invalid.example:not(.no-marker)::before,
.illegal.example:not(.no-marker)::before {
    content: "Invalid Example" counter(example);
}

figcaption {
    counter-increment: figure;
}
figcaption:not(.no-marker)::before {
    content: "Figure " counter(figure) " ";
}</style>
<style>/* style-var-click-highlighting */

    var { cursor: pointer; }
    var.selected0 { background-color: #F4D200; box-shadow: 0 0 0 2px #F4D200; }
    var.selected1 { background-color: #FF87A2; box-shadow: 0 0 0 2px #FF87A2; }
    var.selected2 { background-color: #96E885; box-shadow: 0 0 0 2px #96E885; }
    var.selected3 { background-color: #3EEED2; box-shadow: 0 0 0 2px #3EEED2; }
    var.selected4 { background-color: #EACFB6; box-shadow: 0 0 0 2px #EACFB6; }
    var.selected5 { background-color: #82DDFF; box-shadow: 0 0 0 2px #82DDFF; }
    var.selected6 { background-color: #FFBCF2; box-shadow: 0 0 0 2px #FFBCF2; }
    </style>
<style>/* style-autolinks */

.css.css, .property.property, .descriptor.descriptor {
    color: #005a9c;
    font-size: inherit;
    font-family: inherit;
}
.css::before, .property::before, .descriptor::before {
    content: "‘";
}
.css::after, .property::after, .descriptor::after {
    content: "’";
}
.property, .descriptor {
    /* Don't wrap property and descriptor names */
    white-space: nowrap;
}
.type { /* CSS value <type> */
    font-style: italic;
}
pre .property::before, pre .property::after {
    content: "";
}
[data-link-type="property"]::before,
[data-link-type="propdesc"]::before,
[data-link-type="descriptor"]::before,
[data-link-type="value"]::before,
[data-link-type="function"]::before,
[data-link-type="at-rule"]::before,
[data-link-type="selector"]::before,
[data-link-type="maybe"]::before {
    content: "‘";
}
[data-link-type="property"]::after,
[data-link-type="propdesc"]::after,
[data-link-type="descriptor"]::after,
[data-link-type="value"]::after,
[data-link-type="function"]::after,
[data-link-type="at-rule"]::after,
[data-link-type="selector"]::after,
[data-link-type="maybe"]::after {
    content: "’";
}

[data-link-type].production::before,
[data-link-type].production::after,
.prod [data-link-type]::before,
.prod [data-link-type]::after {
    content: "";
}

[data-link-type=element],
[data-link-type=element-attr] {
    font-family: Menlo, Consolas, "DejaVu Sans Mono", monospace;
    font-size: .9em;
}
[data-link-type=element]::before { content: "<" }
[data-link-type=element]::after  { content: ">" }

[data-link-type=biblio] {
    white-space: pre;
}</style>
<style>/* style-dfn-panel */

.dfn-panel {
    position: absolute;
    z-index: 35;
    height: auto;
    width: -webkit-fit-content;
    width: fit-content;
    max-width: 300px;
    max-height: 500px;
    overflow: auto;
    padding: 0.5em 0.75em;
    font: small Helvetica Neue, sans-serif, Droid Sans Fallback;
    background: #DDDDDD;
    color: black;
    border: outset 0.2em;
}
.dfn-panel:not(.on) { display: none; }
.dfn-panel * { margin: 0; padding: 0; text-indent: 0; }
.dfn-panel > b { display: block; }
.dfn-panel a { color: black; }
.dfn-panel a:not(:hover) { text-decoration: none !important; border-bottom: none !important; }
.dfn-panel > b + b { margin-top: 0.25em; }
.dfn-panel ul { padding: 0; }
.dfn-panel li { list-style: inside; }
.dfn-panel.activated {
    display: inline-block;
    position: fixed;
    left: .5em;
    bottom: 2em;
    margin: 0 auto;
    max-width: calc(100vw - 1.5em - .4em - .5em);
    max-height: 30vh;
}

.dfn-paneled { cursor: pointer; }
</style>
<style>/* style-syntax-highlighting */
pre.idl.highlight { color: #708090; }
.highlight:not(.idl) { background: hsl(24, 20%, 95%); }
code.highlight { padding: .1em; border-radius: .3em; }
pre.highlight, pre > code.highlight { display: block; padding: 1em; margin: .5em 0; overflow: auto; border-radius: 0; }
c-[a] { color: #990055 } /* Keyword.Declaration */
c-[b] { color: #990055 } /* Keyword.Type */
c-[c] { color: #708090 } /* Comment */
c-[d] { color: #708090 } /* Comment.Multiline */
c-[e] { color: #0077aa } /* Name.Attribute */
c-[f] { color: #669900 } /* Name.Tag */
c-[g] { color: #222222 } /* Name.Variable */
c-[k] { color: #990055 } /* Keyword */
c-[l] { color: #000000 } /* Literal */
c-[m] { color: #000000 } /* Literal.Number */
c-[n] { color: #0077aa } /* Name */
c-[o] { color: #999999 } /* Operator */
c-[p] { color: #999999 } /* Punctuation */
c-[s] { color: #a67f59 } /* Literal.String */
c-[t] { color: #a67f59 } /* Literal.String.Single */
c-[u] { color: #a67f59 } /* Literal.String.Double */
c-[cp] { color: #708090 } /* Comment.Preproc */
c-[c1] { color: #708090 } /* Comment.Single */
c-[cs] { color: #708090 } /* Comment.Special */
c-[kc] { color: #990055 } /* Keyword.Constant */
c-[kn] { color: #990055 } /* Keyword.Namespace */
c-[kp] { color: #990055 } /* Keyword.Pseudo */
c-[kr] { color: #990055 } /* Keyword.Reserved */
c-[ld] { color: #000000 } /* Literal.Date */
c-[nc] { color: #0077aa } /* Name.Class */
c-[no] { color: #0077aa } /* Name.Constant */
c-[nd] { color: #0077aa } /* Name.Decorator */
c-[ni] { color: #0077aa } /* Name.Entity */
c-[ne] { color: #0077aa } /* Name.Exception */
c-[nf] { color: #0077aa } /* Name.Function */
c-[nl] { color: #0077aa } /* Name.Label */
c-[nn] { color: #0077aa } /* Name.Namespace */
c-[py] { color: #0077aa } /* Name.Property */
c-[ow] { color: #999999 } /* Operator.Word */
c-[mb] { color: #000000 } /* Literal.Number.Bin */
c-[mf] { color: #000000 } /* Literal.Number.Float */
c-[mh] { color: #000000 } /* Literal.Number.Hex */
c-[mi] { color: #000000 } /* Literal.Number.Integer */
c-[mo] { color: #000000 } /* Literal.Number.Oct */
c-[sb] { color: #a67f59 } /* Literal.String.Backtick */
c-[sc] { color: #a67f59 } /* Literal.String.Char */
c-[sd] { color: #a67f59 } /* Literal.String.Doc */
c-[se] { color: #a67f59 } /* Literal.String.Escape */
c-[sh] { color: #a67f59 } /* Literal.String.Heredoc */
c-[si] { color: #a67f59 } /* Literal.String.Interpol */
c-[sx] { color: #a67f59 } /* Literal.String.Other */
c-[sr] { color: #a67f59 } /* Literal.String.Regex */
c-[ss] { color: #a67f59 } /* Literal.String.Symbol */
c-[vc] { color: #0077aa } /* Name.Variable.Class */
c-[vg] { color: #0077aa } /* Name.Variable.Global */
c-[vi] { color: #0077aa } /* Name.Variable.Instance */
c-[il] { color: #000000 } /* Literal.Number.Integer.Long */
</style>
 <body class="h-entry">
  <div class="head">
   <p data-fill-with="logo"><a class="logo" href="https://www.w3.org/"> <img alt="W3C" height="48" src="https://www.w3.org/StyleSheets/TR/2016/logos/W3C" width="72"> </a> </p>
   <h1 class="p-name no-ref" id="title">CSS Shadow Parts</h1>
   <h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Editor’s Draft, <time class="dt-updated" datetime="1970-01-01">1 January 1970</time></span></h2>
   <details>
    <summary>Specification Metadata</summary>
    <div data-fill-with="spec-metadata">
     <dl>
      <dt>This version:
      <dd><a class="u-url" href="http://drafts.csswg.org/css-shadow-parts/">http://drafts.csswg.org/css-shadow-parts/</a>
      <dt>Latest published version:
      <dd><a href="https://www.w3.org/TR/css-shadow-parts-1/">https://www.w3.org/TR/css-shadow-parts-1/</a>
      <dt class="editor">Editors:
      <dd class="editor p-author h-card vcard" data-editor-id="42199"><a class="p-name fn u-url url" href="http://xanthir.com/contact/">Tab Atkins-Bittner</a> (<span class="p-org org">Google</span>)
      <dd class="editor p-author h-card vcard"><a class="p-name fn u-email email" href="mailto:fergal@chromium.org">Fergal Daly</a> (<span class="p-org org">Google</span>)
      <dt>Suggest an Edit for this Spec:
      <dd><a href="https://github.com/w3c/csswg-drafts/blob/master/css-shadow-parts-1/Overview.bs">GitHub Editor</a>
      <dt>Issue Tracking:
      <dd><a href="https://github.com/w3c/csswg-drafts/labels/css-shadow-parts-1">GitHub Issues</a>
     </dl>
    </div>
   </details>
   <div data-fill-with="warning"></div>
   <p class="copyright" data-fill-with="copyright"><a href="https://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 1970 <a href="https://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a href="https://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>, <a href="https://www.ercim.eu/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>, <a href="https://www.keio.ac.jp/">Keio</a>, <a href="https://ev.buaa.edu.cn/">Beihang</a>). W3C <a href="https://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, <a href="https://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and <a href="https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document">permissive document license</a> rules apply. </p>
   <hr title="Separator for header">
  </div>
  <div class="p-summary" data-fill-with="abstract">
   <h2 class="no-num no-toc no-ref heading settled" id="abstract"><span class="content">Abstract</span></h2>
   <p>This specification defines the <a class="css" data-link-type="maybe" href="#selectordef-part" id="ref-for-selectordef-part">::part()</a> pseudo-element on <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#element-shadow-host" id="ref-for-element-shadow-host">shadow hosts</a>, allowing <span id="ref-for-element-shadow-host①">shadow hosts</span> to selectively expose chosen elements from their <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-shadow-tree" id="ref-for-concept-shadow-tree">shadow tree</a> to the outside page for styling purposes.</p>
    <a href="https://www.w3.org/TR/CSS/">CSS</a> is a language for describing the rendering of structured documents
(such as HTML and XML)
on screen, on paper, etc. 
  </div>
  <h2 class="no-num no-toc no-ref heading settled" id="status"><span class="content">Status of this document</span></h2>
  <div data-fill-with="status">
   <p> This is a public copy of the editors’ draft.
	It is provided for discussion only and may change at any moment.
	Its publication here does not imply endorsement of its contents by W3C.
	Don’t cite this document other than as work in progress. </p>
   <p> <a href="https://github.com/w3c/csswg-drafts/issues">GitHub Issues</a> are preferred for discussion of this specification.
	When filing an issue, please put the text “css-shadow-parts” in the title,
	preferably like this:
	“[css-shadow-parts] <i data-lt>…summary of comment…</i>”.
	All issues and comments are <a href="https://lists.w3.org/Archives/Public/public-css-archive/">archived</a>,
	and there is also a <a href="https://lists.w3.org/Archives/Public/www-style/">historical archive</a>. </p>
   <p> This document was produced by the <a href="https://www.w3.org/Style/CSS/">CSS Working Group</a>. </p>
   <p> This document was produced by a group operating under
	the <a href="https://www.w3.org/Consortium/Patent-Policy/">W3C Patent Policy</a>.
	W3C maintains a <a href="https://www.w3.org/2004/01/pp-impl/32061/status" rel="disclosure">public list of any patent disclosures</a> made in connection with the deliverables of the group;
	that page also includes instructions for disclosing a patent.
	An individual who has actual knowledge of a patent which the individual believes contains <a href="https://www.w3.org/Consortium/Patent-Policy/#def-essential">Essential Claim(s)</a> must disclose the information in accordance with <a href="https://www.w3.org/Consortium/Patent-Policy/#sec-Disclosure">section 6 of the W3C Patent Policy</a>. </p>
   <p> This document is governed by the <a href="https://www.w3.org/2019/Process-20190301/" id="w3c_process_revision">1 March 2019 W3C Process Document</a>. </p>
   <p></p>
  </div>
  <div data-fill-with="at-risk"></div>
  <nav data-fill-with="table-of-contents" id="toc">
   <h2 class="no-num no-toc no-ref" id="contents">Table of Contents</h2>
   <ol class="toc" role="directory">
    <li>
     <a href="#intro"><span class="secno">1</span> <span class="content">Introduction</span></a>
     <ol class="toc">
      <li><a href="#motivation"><span class="secno">1.1</span> <span class="content">Motivation</span></a>
     </ol>
    <li>
     <a href="#exposing"><span class="secno">2</span> <span class="content">Exposing a Shadow Element:</span></a>
     <ol class="toc">
      <li><a href="#part-attr"><span class="secno">2.1</span> <span class="content">Naming a Shadow Element: the <code><span>part</span></code> attribute</span></a>
      <li><a href="#exportparts-attr"><span class="secno">2.2</span> <span class="content">Forwarding a Shadow Element: the <code><span>exportparts</span></code> attribute</span></a>
     </ol>
    <li><a href="#part"><span class="secno">3</span> <span class="content">Selecting a Shadow Element: the <span class="css">::part()</span> pseudo-element</span></a>
    <li><a href="#idl"><span class="secno">4</span> <span class="content">Extensions to the <code class="idl"><span>Element</span></code> Interface</span></a>
    <li>
     <a href="#parsing"><span class="secno">5</span> <span class="content">Microsyntaxes for parsing</span></a>
     <ol class="toc">
      <li><a href="#parsing-mapping"><span class="secno">5.1</span> <span class="content">Rules for parsing part mappings</span></a>
      <li><a href="#parsing-mapping-list"><span class="secno">5.2</span> <span class="content">Rules for parsing a list of part mappings</span></a>
     </ol>
    <li>
     <a href="#conformance"><span class="secno"></span> <span class="content"> Conformance</span></a>
     <ol class="toc">
      <li><a href="#document-conventions"><span class="secno"></span> <span class="content"> Document conventions</span></a>
      <li><a href="#conform-classes"><span class="secno"></span> <span class="content"> Conformance classes</span></a>
      <li>
       <a href="#conform-responsible"><span class="secno"></span> <span class="content"> Requirements for Responsible Implementation of CSS</span></a>
       <ol class="toc">
        <li><a href="#conform-partial"><span class="secno"></span> <span class="content"> Partial Implementations</span></a>
        <li><a href="#conform-future-proofing"><span class="secno"></span> <span class="content"> Implementations of Unstable and Proprietary Features</span></a>
        <li><a href="#conform-testing"><span class="secno"></span> <span class="content"> Implementations of CR-level Features</span></a>
       </ol>
     </ol>
    <li>
     <a href="#index"><span class="secno"></span> <span class="content">Index</span></a>
     <ol class="toc">
      <li><a href="#index-defined-here"><span class="secno"></span> <span class="content">Terms defined by this specification</span></a>
      <li><a href="#index-defined-elsewhere"><span class="secno"></span> <span class="content">Terms defined by reference</span></a>
     </ol>
    <li>
     <a href="#references"><span class="secno"></span> <span class="content">References</span></a>
     <ol class="toc">
      <li><a href="#normative"><span class="secno"></span> <span class="content">Normative References</span></a>
     </ol>
    <li><a href="#idl-index"><span class="secno"></span> <span class="content">IDL Index</span></a>
    <li><a href="#issues-index"><span class="secno"></span> <span class="content">Issues Index</span></a>
   </ol>
  </nav>
  <main>
   <h2 class="heading settled" data-level="1" id="intro"><span class="secno">1. </span><span class="content">Introduction</span><a class="self-link" href="#intro"></a></h2>
   <p>Shadow DOM allows authors to separate their page into "components",
subtrees of markup whose details are only relevant to the component itself,
not the outside page.
This reduces the chance of a style meant for one part of the page
accidentally over-applying and making a different part of the page look wrong.
However, this styling barrier also makes it harder for a page to interact with its components
when it actually <em>wants</em> to do so.</p>
   <p>This specification defines the <a class="css" data-link-type="maybe" href="#selectordef-part" id="ref-for-selectordef-part①">::part()</a> pseudo-element,
which allows an author to style specific, purposely exposed elements in a <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-shadow-tree" id="ref-for-concept-shadow-tree①">shadow tree</a> from the outside page’s context.
In combination with <a data-link-type="dfn" href="https://drafts.csswg.org/css-variables-1/#custom-property" id="ref-for-custom-property">custom properties</a>,
which let the outside page pass particular values
(such as theme colors)
into the component for it to do with as it will,
these pseudo-elements allow components and the outside page
to interact in safe, powerful ways,
maintaining encapsulation
without surrendering all control.</p>
   <h3 class="heading settled" data-level="1.1" id="motivation"><span class="secno">1.1. </span><span class="content">Motivation</span><a class="self-link" href="#motivation"></a></h3>
   <p>For custom elements to be fully useful and as capable as built-in elements
it should be possible for parts of them to be styled from outside.
Exactly what can be styled from outside should be controlled by the element author.
Also, it should be possible for a custom element to present a stable "API" for styling.
That is, the selector used to style a part of a custom element
should not expose or require knowledge of the internal details of the element.
The custom element author should be able to change the internal details of the element
while leaving the selectors untouched.</p>
   <p>The previous proposed method for styling inside the shadow tree,
the >>> combinator,
turned out to be <em>too powerful</em> for its own good;
it exposed too much of a component’s internal structure to scrutiny,
defeating some of the encapsulation benefits that using Shadow DOM brings.
For this,
and other performance-related reasons,
the >>> combinator was eventually removed from the <a data-link-type="dfn" href="https://drafts.csswg.org/selectors-4/#live-profile" id="ref-for-live-profile">live profile</a>.</p>
   <p>This left us with using <a data-link-type="dfn" href="https://drafts.csswg.org/css-variables-1/#custom-property" id="ref-for-custom-property①">custom properties</a> as the only way to style into a shadow tree:
the component would advertise that it uses certain <span id="ref-for-custom-property②">custom properties</span> to style its internals,
and the outer page could then set those properties as it wished on the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#element-shadow-host" id="ref-for-element-shadow-host②">shadow host</a>,
letting inheritance push the values down to where they were needed.
This works very well for many simple theming use-cases.</p>
   <p>However, there are some cases where this falls down.
If a component wishes to allow arbitrary styling of something in its shadow tree,
the only way to do so is to define hundreds of <a data-link-type="dfn" href="https://drafts.csswg.org/css-variables-1/#custom-property" id="ref-for-custom-property③">custom properties</a> (one per CSS property they wish to allow control of),
which is obviously ridiculous
for both usability and performance reasons.
The situation is compounded if authors wish to style the component differently
based on pseudo-classes like <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/selectors-4/#hover-pseudo" id="ref-for-hover-pseudo">:hover</a>;
the component needs to duplicate the <span id="ref-for-custom-property④">custom properties</span> used
for each pseudo-class
(and each combination,
like <span class="css">:hover:focus</span>,
resulting in a combinatorial explosion).
This makes the usability and performance problems even worse.</p>
   <p>We introduce <a class="css" data-link-type="maybe" href="#selectordef-part" id="ref-for-selectordef-part②">::part()</a> to handle this case much more elegantly and performantly.
Rather than bundling everything into <a data-link-type="dfn" href="https://drafts.csswg.org/css-variables-1/#custom-property" id="ref-for-custom-property⑤">custom property</a> names,
the functionality lives in selectors and style rule syntax,
like it’s meant to.
This is far more usable for both component authors
and component users,
should have much better performance,
and allows for better encapsulation/API surface.</p>
   <p>It’s important to note that <a class="css" data-link-type="maybe" href="#selectordef-part" id="ref-for-selectordef-part③">::part()</a> offers <em>absolutely zero new theoretical power</em>.
It is not a rehash of the <span class="css">>>></span> combinator,
it is simply a more convenient and consistent syntax
for something authors can already do with <a data-link-type="dfn" href="https://drafts.csswg.org/css-variables-1/#custom-property" id="ref-for-custom-property⑥">custom properties</a>.
By separating out the explicitly "published" parts of an element
(the <a data-link-type="dfn" href="#shadow-root-part-element-map" id="ref-for-shadow-root-part-element-map">part element map</a>)
from the sub-parts that it merely happens to contain,
it also helps with encapsulation,
as authors can use <span class="css" id="ref-for-selectordef-part④">::part()</span> without fear of accidental over-styling.</p>
   <h2 class="heading settled" data-level="2" id="exposing"><span class="secno">2. </span><span class="content">Exposing a Shadow Element:</span><a class="self-link" href="#exposing"></a></h2>
    Elements in a <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-shadow-tree" id="ref-for-concept-shadow-tree②">shadow tree</a> may be exported for styling by stylesheets outside the tree
using the part and exportparts attributes. 
   <p>Each element has a <dfn class="dfn-paneled" data-dfn-for="element" data-dfn-type="dfn" data-export id="element-part-name-list">part name list</dfn> which is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ordered-set" id="ref-for-ordered-set">ordered set</a> of tokens.</p>
   <p>Each element has a <dfn class="dfn-paneled" data-dfn-for="element" data-dfn-type="dfn" data-export id="element-forwarded-part-name-list">forwarded part name list</dfn> which is a <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list" id="ref-for-list">list</a> of <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#pair" id="ref-for-pair">pairs</a> containing a <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#string" id="ref-for-string">string</a> for the inner part being forwarded
and a <span id="ref-for-string①">string</span> giving the name it will be exposed as.</p>
   <p>Each <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-shadow-root" id="ref-for-concept-shadow-root">shadow root</a> can be thought of as having a <dfn class="dfn-paneled" data-dfn-for="shadow root" data-dfn-type="dfn" data-export id="shadow-root-part-element-map">part element map</dfn> with keys that are <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#string" id="ref-for-string②">strings</a> and values that are <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ordered-set" id="ref-for-ordered-set①">ordered sets</a> of elements.</p>
   <p>The <a data-link-type="dfn" href="#shadow-root-part-element-map" id="ref-for-shadow-root-part-element-map①">part element map</a> is described
only as part of the algorithm for calculating style in this spec.
It is not exposed via the DOM,
as calculating it may be expensive
and exposing it could allow access to elements inside closed shadow roots.</p>
   <p><a data-link-type="dfn" href="#shadow-root-part-element-map" id="ref-for-shadow-root-part-element-map②">Part element maps</a> are affected by the addition and removal of elements
and changes to the <a data-link-type="dfn" href="#element-part-name-list" id="ref-for-element-part-name-list">part name lists</a> and <a data-link-type="dfn" href="#element-forwarded-part-name-list" id="ref-for-element-forwarded-part-name-list">forwarded part name lists</a> of elements in the DOM.</p>
   <div class="algorithm" data-algorithm="calculate the part element map">
     To <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="calculate-the-part-element-map">calculate the <a data-link-type="dfn" href="#shadow-root-part-element-map" id="ref-for-shadow-root-part-element-map③">part element map</a></dfn> of a shadow root, <var>outerRoot</var>: 
    <ol>
     <li data-md>
      <p>For each <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-tree-descendant" id="ref-for-concept-tree-descendant">descendant</a> <var>el</var> within <var>outerRoot</var>:</p>
      <ol>
       <li data-md>
        <p>For each <var>name</var> in <var>el</var>’s <a data-link-type="dfn" href="#element-part-name-list" id="ref-for-element-part-name-list①">part name list</a>, <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list-append" id="ref-for-list-append">append</a> <var>el</var> to <var>outerRoot</var>’s <a data-link-type="dfn" href="#shadow-root-part-element-map" id="ref-for-shadow-root-part-element-map④">part element map</a>[<var>name</var>].</p>
       <li data-md>
        <p>If <var>el</var> is a <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#element-shadow-host" id="ref-for-element-shadow-host③">shadow host</a> itself
then let <var>innerRoot</var> be its shadow root.</p>
       <li data-md>
        <p><a data-link-type="dfn" href="#calculate-the-part-element-map" id="ref-for-calculate-the-part-element-map">Calculate</a> <var>innerRoot</var>’s <a data-link-type="dfn" href="#shadow-root-part-element-map" id="ref-for-shadow-root-part-element-map⑤">part element map</a>.</p>
       <li data-md>
        <p>For each <var>innerName</var>/<var>outerName</var> in <var>el</var>’s <a data-link-type="dfn" href="#element-forwarded-part-name-list" id="ref-for-element-forwarded-part-name-list①">forwarded part name list</a>:</p>
        <ol>
         <li data-md>
          <p>Let <var>innerParts</var> be <var>innerRoot</var>’s <a data-link-type="dfn" href="#shadow-root-part-element-map" id="ref-for-shadow-root-part-element-map⑥">part element map</a>[<var>innerName</var>]</p>
         <li data-md>
          <p><a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list-append" id="ref-for-list-append①">Append</a> the elements in <var>innerParts</var> to <var>outerRoot</var>’s <a data-link-type="dfn" href="#shadow-root-part-element-map" id="ref-for-shadow-root-part-element-map⑦">part element map</a>[<var>outerName</var>]</p>
        </ol>
      </ol>
    </ol>
   </div>
   <h3 class="heading settled" data-level="2.1" id="part-attr"><span class="secno">2.1. </span><span class="content">Naming a Shadow Element: the <code><a data-link-type="element-sub" href="#element-attrdef-html-global-part" id="ref-for-element-attrdef-html-global-part">part</a></code> attribute</span><a class="self-link" href="#part-attr"></a></h3>
   <p>Any element in a shadow tree can have a <dfn class="dfn-paneled" data-dfn-for="html-global" data-dfn-type="element-attr" data-export id="element-attrdef-html-global-part"><code>part</code></dfn> attribute.
This is used to expose the element outside of the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-shadow-tree" id="ref-for-concept-shadow-tree③">shadow tree</a>.</p>
   <p>The part attribute is parsed as a space-separated list of tokens representing the part names of this element.</p>
   <p class="note" role="note"><span>Note:</span> It’s okay to give a part multiple names.
The "part name" should be considered similar to a class,
not an id or tagname.</p>
<pre class="example" id="example-a2e8f894"><a class="self-link" href="#example-a2e8f894"></a>&lt;style>
  c-e<b>::part(textspan)</b> { color: red; }
&lt;/style>

&lt;template id="c-e-template">
  &lt;span <b>part="textspan"</b>>This text will be red&lt;/span>
&lt;/template>
&lt;c-e>&lt;/c-e>
&lt;script>
  // Add template as custom element c-e
  ...
&lt;/script>
</pre>
   <h3 class="heading settled" data-level="2.2" id="exportparts-attr"><span class="secno">2.2. </span><span class="content">Forwarding a Shadow Element: the <code><a data-link-type="element-sub" href="#element-attrdef-html-global-exportparts" id="ref-for-element-attrdef-html-global-exportparts">exportparts</a></code> attribute</span><a class="self-link" href="#exportparts-attr"></a></h3>
    Any element in a shadow tree can have a <dfn class="dfn-paneled" data-dfn-for="html-global" data-dfn-type="element-attr" data-export id="element-attrdef-html-global-exportparts"><code>exportparts</code></dfn> attribute.
If the element is a shadow host,
this is used to allow styling of parts from hosts inside the <span id="ref-for-concept-shadow-tree④">shadow tree</span> by rules outside this the <span id="ref-for-concept-shadow-tree⑤">shadow tree</span> (as if they were elements in the same tree as the host,
named by a part attribute). 
   <p>The exportparts attribute is parsed as a comma-separated list of part mappings.
Each part mapping is one of:</p>
   <dl class="switch">
    <dt data-md><code>innerIdent : outerIdent</code>
    <dd data-md>
     <p>Adds <code>innerIdent</code>/<code>outerIdent</code> to el’s <a data-link-type="dfn" href="#element-forwarded-part-name-list" id="ref-for-element-forwarded-part-name-list②">forwarded part name list</a>.</p>
    <dt data-md><code>ident</code>
    <dd data-md>
     <p>Adds <code>ident</code>/<code>ident</code> to el’s <a data-link-type="dfn" href="#element-forwarded-part-name-list" id="ref-for-element-forwarded-part-name-list③">forwarded part name list</a>.</p>
     <p class="note" role="note"><span>Note:</span> This is shorthand for <code>ident : ident</code>.</p>
    <dt data-md>anything else
    <dd data-md>
     <p>Ignored for error-recovery / future compatibility.</p>
   </dl>
   <p class="note" role="note"><span>Note:</span> It’s okay to map a sub-part to several names.</p>
<pre class="example" id="example-8f835643"><a class="self-link" href="#example-8f835643"></a>&lt;style>
  c-e<b>::part(textspan)</b> { color: red; }
&lt;/style>

&lt;template id="c-e-outer-template">
  &lt;c-e-inner <b>exportparts="innerspan: textspan"</b>>&lt;/c-e-inner>
&lt;/template>

&lt;template id="c-e-inner-template">
  &lt;span <b>part="innerspan"</b>>
    This text will be red because the containing shadow
    host forwards <b>innerspan</b> to the document as "textspan"
    and the document style matches it.
  &lt;/span>
  &lt;span <b>part="textspan"</b>>
    This text will not be red because <b>textspan</b> in the document style
    cannot match against the part inside the inner custom element
    if it is not forwarded.
  &lt;/span>
&lt;/template>

&lt;c-e>&lt;/c-e>
&lt;script>
  // Add template as custom elements c-e-inner, c-e-outer
    ...
&lt;/script>
</pre>
   <h2 class="heading settled" data-level="3" id="part"><span class="secno">3. </span><span class="content">Selecting a Shadow Element: the <a class="css" data-link-type="maybe" href="#selectordef-part" id="ref-for-selectordef-part⑤">::part()</a> pseudo-element</span><a class="self-link" href="#part"></a></h2>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="selectordef-part">::part()</dfn> pseudo-element
allows you to select elements that have been exposed via a <code><a data-link-type="element-sub" href="#element-attrdef-html-global-part" id="ref-for-element-attrdef-html-global-part①">part</a></code> attribute.
The syntax is:</p>
<pre class="prod">::part() = ::part( <a class="production" data-link-type="type" href="https://drafts.csswg.org/css-values-4/#typedef-ident" id="ref-for-typedef-ident">&lt;ident></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-one-plus" id="ref-for-mult-one-plus">+</a> )
</pre>
   <p>The <a class="css" data-link-type="maybe" href="#selectordef-part" id="ref-for-selectordef-part⑥">::part()</a> pseudo-element only matches anything
when the <a data-link-type="dfn" href="https://drafts.csswg.org/selectors-4/#originating-element" id="ref-for-originating-element">originating element</a> is a <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#element-shadow-host" id="ref-for-element-shadow-host④">shadow host</a>.
If the <span id="ref-for-originating-element①">originating element’s</span> <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-shadow-root" id="ref-for-concept-shadow-root①">shadow root’s</a> <a data-link-type="dfn" href="#shadow-root-part-element-map" id="ref-for-shadow-root-part-element-map⑧">part element map</a> <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#map-exists" id="ref-for-map-exists">contains</a> all of the specified <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-4/#typedef-ident" id="ref-for-typedef-ident①">&lt;ident></a>s, <span class="css" id="ref-for-selectordef-part⑦">::part()</span> matches the element or elements keyed to that <span class="production" id="ref-for-typedef-ident②">&lt;ident></span>.
Otherwise, it matches nothing.</p>
   <div class="example" id="example-ddbe60b5"><a class="self-link" href="#example-ddbe60b5"></a> For example,
    if you have a custom button
    that contains a "label" element that is exposed for styling
    (via <code>part="label"</code>),
    you can select it with <span class="css">#the-button::part(label)</span>. </div>
   <div class="example" id="example-72ff019b">
    <a class="self-link" href="#example-72ff019b"></a> Part names act similarly to classes:
	multiple elements can have the same part name,
	and a single element can have multiple part names. 
    <p>A tabstrip control might have multiple elements
	with <code>part="tab"</code>,
	all of which are selected by <span class="css">::part(tab)</span>.</p>
    <p>If a single tab is active at a time,
	it can be specially indicated with <code>part="tab active"</code> and then selected by <span class="css">::part(tab active)</span> (or <span class="css">::part(active tab)</span>, as order doesn’t matter).</p>
   </div>
   <p>The <a class="css" data-link-type="maybe" href="#selectordef-part" id="ref-for-selectordef-part⑧">::part()</a> pseudo-element can take additional pseudo-classes after it,
such as <span class="css">x-button::part(label):hover</span>,
but never matches the <a data-link-type="dfn" href="https://drafts.csswg.org/selectors-4/#structural-pseudo-classes" id="ref-for-structural-pseudo-classes">structural pseudo-classes</a> or any other pseudo-classes that match based on tree information
rather than local element information.</p>
   <p>The <a class="css" data-link-type="maybe" href="#selectordef-part" id="ref-for-selectordef-part⑨">::part()</a> pseudo-element can also take additional pseudo-elements after it,
such as <span class="css">x-button::part(label)::before</span>,
but never match additional <span class="css" id="ref-for-selectordef-part①⓪">::part()</span>s.</p>
   <div class="example" id="example-11b18654">
    <a class="self-link" href="#example-11b18654"></a> For example, <span class="css">x-panel::part(confirm-button)::part(label)</span> never matches anything.
    This is because doing so would expose more structural information
    than is intended. 
    <p>If the <code>&lt;x-panel></code>’s internal confirm button had used something like <code>part="label => confirm-label"</code> to forward the button’s internal parts up into the panel’s own <a data-link-type="dfn" href="#shadow-root-part-element-map" id="ref-for-shadow-root-part-element-map⑨">part element map</a>,
    then a selector like <span class="css">x-panel::part(confirm-label)</span> would select just the one button’s label,
    ignoring any other labels.</p>
   </div>
   <h2 class="heading settled" data-level="4" id="idl"><span class="secno">4. </span><span class="content">Extensions to the <code class="idl"><a data-link-type="idl" href="https://dom.spec.whatwg.org/#element" id="ref-for-element">Element</a></code> Interface</span><a class="self-link" href="#idl"></a></h2>
<pre class="idl highlight def"><c- b>partial</c-> <c- b>interface</c-> <a class="idl-code" data-link-type="interface" href="https://dom.spec.whatwg.org/#element" id="ref-for-element①"><c- g>Element</c-></a> {
  [<a class="idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SameObject" id="ref-for-SameObject"><c- g>SameObject</c-></a>, <a class="idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#PutForwards" id="ref-for-PutForwards"><c- g>PutForwards</c-></a>=<a class="idl-code" data-link-type="attribute" href="https://dom.spec.whatwg.org/#dom-domtokenlist-value" id="ref-for-dom-domtokenlist-value"><c- n>value</c-></a>] <c- b>readonly</c-> <c- b>attribute</c-> <a class="n" data-link-type="idl-name" href="https://dom.spec.whatwg.org/#domtokenlist" id="ref-for-domtokenlist"><c- n>DOMTokenList</c-></a> <dfn class="idl-code" data-dfn-for="Element" data-dfn-type="attribute" data-export data-readonly data-type="DOMTokenList" id="dom-element-part"><code><c- g>part</c-></code><a class="self-link" href="#dom-element-part"></a></dfn>;
};
</pre>
   <p>The part attribute’s getter must return a DOMTokenList object
whose associated element is the context object
and whose associated attribute’s local name is part.
The token set of this particular DOMTokenList object are also known as the element’s parts.</p>
   <p class="issue" id="issue-853df044"><a class="self-link" href="#issue-853df044"></a> Define this as a superglobal in the DOM spec. <a href="https://github.com/w3c/csswg-drafts/issues/3424">&lt;https://github.com/w3c/csswg-drafts/issues/3424></a></p>
   <h2 class="heading settled" data-level="5" id="parsing"><span class="secno">5. </span><span class="content">Microsyntaxes for parsing</span><a class="self-link" href="#parsing"></a></h2>
   <h3 class="heading settled" data-level="5.1" id="parsing-mapping"><span class="secno">5.1. </span><span class="content">Rules for parsing part mappings</span><a class="self-link" href="#parsing-mapping"></a></h3>
   <p>A <dfn data-dfn-type="dfn" data-export id="valid-part-mapping">valid part mapping<a class="self-link" href="#valid-part-mapping"></a></dfn> is a <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#pair" id="ref-for-pair①">pair</a> of tokens
separated by a U+003A COLON character
and any number of space characters before or after the U+003A COLON
The tokens must not contain U+003A COLON or U+002C COMMA characters.</p>
   <p>The rules for parsing a part mapping are as follows:</p>
   <ol>
    <li data-md>
     <p>Let <var>input</var> be the string being parsed.</p>
    <li data-md>
     <p>Let <var>position</var> be a pointer into <var>input</var>, initially pointing at the start of the string.</p>
    <li data-md>
     <p><a data-link-type="dfn" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" id="ref-for-collect-a-sequence-of-code-points">Collect a sequence of code points</a> that are space characters</p>
    <li data-md>
     <p><a data-link-type="dfn" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" id="ref-for-collect-a-sequence-of-code-points①">Collect a sequence of code points</a> that are not space characters or U+003A COLON characters,
and let <var>first token</var> be the result.</p>
    <li data-md>
     <p>If <var>first token</var> is empty then return error.</p>
    <li data-md>
     <p><a data-link-type="dfn" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" id="ref-for-collect-a-sequence-of-code-points②">Collect a sequence of code points</a> that are space characters.</p>
    <li data-md>
     <p>If the end of the <var>input</var> has been reached, return the <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#pair" id="ref-for-pair②">pair</a> <var>first token</var>/<var>first token</var></p>
    <li data-md>
     <p>If character at <var>position</var> is not a U+003A COLON character, return error.</p>
    <li data-md>
     <p>Consume the U+003A COLON character.</p>
    <li data-md>
     <p><a data-link-type="dfn" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" id="ref-for-collect-a-sequence-of-code-points③">Collect a sequence of code points</a> that are space characters.</p>
    <li data-md>
     <p><a data-link-type="dfn" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" id="ref-for-collect-a-sequence-of-code-points④">Collect a sequence of code points</a> that are not space characters or U+003A COLON characters.
and let <var>second token</var> be the result.</p>
    <li data-md>
     <p>If <var>second token</var> is empty then return error.</p>
    <li data-md>
     <p><a data-link-type="dfn" href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points" id="ref-for-collect-a-sequence-of-code-points⑤">Collect a sequence of code points</a> that are space characters.</p>
    <li data-md>
     <p>If <var>position</var> is not past the end of <var>input</var> then return error.</p>
    <li data-md>
     <p>Return the <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#pair" id="ref-for-pair③">pair</a> <var>first token</var>/<var>second token</var>.</p>
   </ol>
   <h3 class="heading settled" data-level="5.2" id="parsing-mapping-list"><span class="secno">5.2. </span><span class="content">Rules for parsing a list of part mappings</span><a class="self-link" href="#parsing-mapping-list"></a></h3>
   <p>A <dfn data-dfn-type="dfn" data-export id="valid-list-of-part-mappings">valid list of part mappings<a class="self-link" href="#valid-list-of-part-mappings"></a></dfn> is a number of valid part mappings
separated by a U+002C COMMA character
and any number of space characters before or after the U+002C COMMA</p>
   <p>The rules for parsing a list of part mappings are as follow:</p>
   <ol>
    <li data-md>
     <p>Let <var>input</var> be the string being parsed.</p>
    <li data-md>
     <p><span data-x="split a string on commas">Split the string <var>input</var> on
commas</span>. Let <var>unparsed mappings</var> be the resulting list of strings.</p>
    <li data-md>
     <p>Let <var>mappings</var> be an initially empty <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list" id="ref-for-list①">list</a> of <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#pair" id="ref-for-pair④">pairs</a> of tokens.
This <span id="ref-for-list②">list</span> will be the result of this algorithm.</p>
    <li data-md>
     <p>For each string <var>unparsed mapping</var> in <var>unparsed mappings</var>,
run the following substeps:</p>
     <ol>
      <li data-md>
       <p>If <var>unparsed mapping</var> is empty or contains only space characters,
continue to the next iteration of the loop.</p>
      <li data-md>
       <p>Let <var>mapping</var> be the result of parsing <var>unparsed mapping</var> using the <span>rules for parsing part mappings</span>.</p>
      <li data-md>
       <p>If <var>mapping</var> is an error then continue to the next iteration of the loop.
This allows clients to skip over new syntax that is not understood.</p>
      <li data-md>
       <p>Append <var>mapping</var> to <var>mappings</var>.</p>
     </ol>
   </ol>
  </main>
  <h2 class="no-ref no-num heading settled" id="conformance"><span class="content"> Conformance</span><a class="self-link" href="#conformance"></a></h2>
  <h3 class="heading settled" id="document-conventions"><span class="content"> Document conventions</span><a class="self-link" href="#document-conventions"></a></h3>
  <p>Conformance requirements are expressed with a combination of
	descriptive assertions and RFC 2119 terminology. The key words “MUST”,
	“MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”,
	“RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this
	document are to be interpreted as described in RFC 2119.
	However, for readability, these words do not appear in all uppercase
	letters in this specification. </p>
  <p>All of the text of this specification is normative except sections
	explicitly marked as non-normative, examples, and notes. <a data-link-type="biblio" href="#biblio-rfc2119">[RFC2119]</a> </p>
  <p>Examples in this specification are introduced with the words “for example”
	or are set apart from the normative text with <code>class="example"</code>,
	like this: </p>
  <div class="example" id="example-ae2b6bc0">
   <a class="self-link" href="#example-ae2b6bc0"></a> 
   <p>This is an example of an informative example. </p>
  </div>
  <p>Informative notes begin with the word “Note” and are set apart from the
	normative text with <code>class="note"</code>, like this: </p>
  <p class="note" role="note">Note, this is an informative note. </p>
  <p>Advisements are normative sections styled to evoke special attention and are
	set apart from other normative text with <code>&lt;strong class="advisement"></code>, like
	this: <strong class="advisement"> UAs MUST provide an accessible alternative. </strong> </p>
  <h3 class="heading settled" id="conform-classes"><span class="content"> Conformance classes</span><a class="self-link" href="#conform-classes"></a></h3>
  <p>Conformance to this specification
	is defined for three conformance classes: </p>
  <dl>
   <dt>style sheet 
   <dd>A <a href="http://www.w3.org/TR/CSS2/conform.html#style-sheet">CSS
			style sheet</a>. 
   <dt>renderer 
   <dd>A <a href="http://www.w3.org/TR/CSS2/conform.html#user-agent">UA</a> that interprets the semantics of a style sheet and renders
			documents that use them. 
   <dt>authoring tool 
   <dd>A <a href="http://www.w3.org/TR/CSS2/conform.html#user-agent">UA</a> that writes a style sheet. 
  </dl>
  <p>A style sheet is conformant to this specification
	if all of its statements that use syntax defined in this module are valid
	according to the generic CSS grammar and the individual grammars of each
	feature defined in this module. </p>
  <p>A renderer is conformant to this specification
	if, in addition to interpreting the style sheet as defined by the
	appropriate specifications, it supports all the features defined
	by this specification by parsing them correctly
	and rendering the document accordingly. However, the inability of a
	UA to correctly render a document due to limitations of the device
	does not make the UA non-conformant. (For example, a UA is not
	required to render color on a monochrome monitor.) </p>
  <p>An authoring tool is conformant to this specification
	if it writes style sheets that are syntactically correct according to the
	generic CSS grammar and the individual grammars of each feature in
	this module, and meet all other conformance requirements of style sheets
	as described in this module. </p>
  <h3 class="heading settled" id="conform-responsible"><span class="content"> Requirements for Responsible Implementation of CSS</span><a class="self-link" href="#conform-responsible"></a></h3>
  <p>The following sections define several conformance requirements
		for implementing CSS responsibly,
		in a way that promotes interoperability in the present and future. </p>
  <h4 class="heading settled" id="conform-partial"><span class="content"> Partial Implementations</span><a class="self-link" href="#conform-partial"></a></h4>
  <p>So that authors can exploit the forward-compatible parsing rules to assign fallback values, <strong>CSS renderers <em>must</em> treat as invalid
		(and <a href="http://www.w3.org/TR/CSS2/conform.html#ignore">ignore as appropriate</a>)
		any at-rules, properties, property values, keywords, and other syntactic constructs
		for which they have no usable level of support</strong>.
		In particular, user agents <em>must not</em> selectively ignore
		unsupported property values and honor supported values in a single multi-value property declaration:
		if any value is considered invalid (as unsupported values must be),
		CSS requires that the entire declaration be ignored. </p>
  <h4 class="heading settled" id="conform-future-proofing"><span class="content"> Implementations of Unstable and Proprietary Features</span><a class="self-link" href="#conform-future-proofing"></a></h4>
  <p>To avoid clashes with future stable CSS features,
		the CSSWG recommends <a href="http://www.w3.org/TR/CSS/#future-proofing">following best practices</a> for the implementation of <a href="http://www.w3.org/TR/CSS/#unstable">unstable</a> features and <a href="http://www.w3.org/TR/CSS/#proprietary-extension">proprietary extensions</a> to CSS. </p>
  <h4 class="heading settled" id="conform-testing"><span class="content"> Implementations of CR-level Features</span><a class="self-link" href="#conform-testing"></a></h4>
  <p>Once a specification reaches the Candidate Recommendation stage,
		implementers should release an <a data-link-type="dfn" href="http://www.w3.org/TR/CSS/#vendor-prefix">unprefixed</a> implementation
		of any CR-level feature they can demonstrate
		to be correctly implemented according to spec,
		and should avoid exposing a prefixed variant of that feature. </p>
  <p>To establish and maintain the interoperability of CSS across
		implementations, the CSS Working Group requests that non-experimental
		CSS renderers submit an implementation report (and, if necessary, the
		testcases used for that implementation report) to the W3C before
		releasing an unprefixed implementation of any CSS features. Testcases
		submitted to W3C are subject to review and correction by the CSS
		Working Group. </p>
  <p>
   Further information on submitting testcases and implementation reports
		can be found from on the CSS Working Group’s website at <a href="http://www.w3.org/Style/CSS/Test/">http://www.w3.org/Style/CSS/Test/</a>.
		Questions should be directed to the <a href="http://lists.w3.org/Archives/Public/public-css-testsuite">public-css-testsuite@w3.org</a> mailing list. 
<script src="https://www.w3.org/scripts/TR/2016/fixup.js"></script>
  </p>
  <h2 class="no-num no-ref heading settled" id="index"><span class="content">Index</span><a class="self-link" href="#index"></a></h2>
  <h3 class="no-num no-ref heading settled" id="index-defined-here"><span class="content">Terms defined by this specification</span><a class="self-link" href="#index-defined-here"></a></h3>
  <ul class="index">
   <li><a href="#calculate-the-part-element-map">calculate the part element map</a><span>, in §2</span>
   <li><a href="#element-attrdef-html-global-exportparts">exportparts</a><span>, in §2.2</span>
   <li><a href="#element-forwarded-part-name-list">forwarded part name list</a><span>, in §2</span>
   <li><a href="#selectordef-part">::part()</a><span>, in §3</span>
   <li>
    part
    <ul>
     <li><a href="#dom-element-part">attribute for Element</a><span>, in §4</span>
     <li><a href="#element-attrdef-html-global-part">element-attr for html-global</a><span>, in §2.1</span>
    </ul>
   <li><a href="#shadow-root-part-element-map">part element map</a><span>, in §2</span>
   <li><a href="#element-part-name-list">part name list</a><span>, in §2</span>
   <li><a href="#valid-list-of-part-mappings">valid list of part mappings</a><span>, in §5.2</span>
   <li><a href="#valid-part-mapping">valid part mapping</a><span>, in §5.1</span>
  </ul>
  <aside class="dfn-panel" data-for="term-for-mult-one-plus">
   <a href="https://drafts.csswg.org/css-values-4/#mult-one-plus">https://drafts.csswg.org/css-values-4/#mult-one-plus</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-mult-one-plus">3. Selecting a Shadow Element: the ::part() pseudo-element</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-typedef-ident">
   <a href="https://drafts.csswg.org/css-values-4/#typedef-ident">https://drafts.csswg.org/css-values-4/#typedef-ident</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-typedef-ident">3. Selecting a Shadow Element: the ::part() pseudo-element</a> <a href="#ref-for-typedef-ident①">(2)</a> <a href="#ref-for-typedef-ident②">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-custom-property">
   <a href="https://drafts.csswg.org/css-variables-1/#custom-property">https://drafts.csswg.org/css-variables-1/#custom-property</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-custom-property">1. Introduction</a>
    <li><a href="#ref-for-custom-property①">1.1. Motivation</a> <a href="#ref-for-custom-property②">(2)</a> <a href="#ref-for-custom-property③">(3)</a> <a href="#ref-for-custom-property④">(4)</a> <a href="#ref-for-custom-property⑤">(5)</a> <a href="#ref-for-custom-property⑥">(6)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-domtokenlist">
   <a href="https://dom.spec.whatwg.org/#domtokenlist">https://dom.spec.whatwg.org/#domtokenlist</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-domtokenlist">4. Extensions to the Element Interface</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-element">
   <a href="https://dom.spec.whatwg.org/#element">https://dom.spec.whatwg.org/#element</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-element">4. Extensions to the Element Interface</a> <a href="#ref-for-element①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-concept-tree-descendant">
   <a href="https://dom.spec.whatwg.org/#concept-tree-descendant">https://dom.spec.whatwg.org/#concept-tree-descendant</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-concept-tree-descendant">2. Exposing a Shadow Element:</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-element-shadow-host">
   <a href="https://dom.spec.whatwg.org/#element-shadow-host">https://dom.spec.whatwg.org/#element-shadow-host</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-element-shadow-host②">1.1. Motivation</a>
    <li><a href="#ref-for-element-shadow-host③">2. Exposing a Shadow Element:</a>
    <li><a href="#ref-for-element-shadow-host④">3. Selecting a Shadow Element: the ::part() pseudo-element</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-concept-shadow-root">
   <a href="https://dom.spec.whatwg.org/#concept-shadow-root">https://dom.spec.whatwg.org/#concept-shadow-root</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-concept-shadow-root">2. Exposing a Shadow Element:</a>
    <li><a href="#ref-for-concept-shadow-root①">3. Selecting a Shadow Element: the ::part() pseudo-element</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-concept-shadow-tree">
   <a href="https://dom.spec.whatwg.org/#concept-shadow-tree">https://dom.spec.whatwg.org/#concept-shadow-tree</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-concept-shadow-tree①">1. Introduction</a>
    <li><a href="#ref-for-concept-shadow-tree②">2. Exposing a Shadow Element:</a>
    <li><a href="#ref-for-concept-shadow-tree③">2.1. Naming a Shadow Element: the part attribute</a>
    <li><a href="#ref-for-concept-shadow-tree④">2.2. Forwarding a Shadow Element: the exportparts attribute</a> <a href="#ref-for-concept-shadow-tree⑤">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-dom-domtokenlist-value">
   <a href="https://dom.spec.whatwg.org/#dom-domtokenlist-value">https://dom.spec.whatwg.org/#dom-domtokenlist-value</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-domtokenlist-value">4. Extensions to the Element Interface</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-list-append">
   <a href="https://infra.spec.whatwg.org/#list-append">https://infra.spec.whatwg.org/#list-append</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-list-append">2. Exposing a Shadow Element:</a> <a href="#ref-for-list-append①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-collect-a-sequence-of-code-points">
   <a href="https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points">https://infra.spec.whatwg.org/#collect-a-sequence-of-code-points</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-collect-a-sequence-of-code-points">5.1. Rules for parsing part mappings</a> <a href="#ref-for-collect-a-sequence-of-code-points①">(2)</a> <a href="#ref-for-collect-a-sequence-of-code-points②">(3)</a> <a href="#ref-for-collect-a-sequence-of-code-points③">(4)</a> <a href="#ref-for-collect-a-sequence-of-code-points④">(5)</a> <a href="#ref-for-collect-a-sequence-of-code-points⑤">(6)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-map-exists">
   <a href="https://infra.spec.whatwg.org/#map-exists">https://infra.spec.whatwg.org/#map-exists</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-map-exists">3. Selecting a Shadow Element: the ::part() pseudo-element</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-list">
   <a href="https://infra.spec.whatwg.org/#list">https://infra.spec.whatwg.org/#list</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-list">2. Exposing a Shadow Element:</a>
    <li><a href="#ref-for-list①">5.2. Rules for parsing a list of part mappings</a> <a href="#ref-for-list②">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-ordered-set">
   <a href="https://infra.spec.whatwg.org/#ordered-set">https://infra.spec.whatwg.org/#ordered-set</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-ordered-set">2. Exposing a Shadow Element:</a> <a href="#ref-for-ordered-set①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-pair">
   <a href="https://infra.spec.whatwg.org/#pair">https://infra.spec.whatwg.org/#pair</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-pair">2. Exposing a Shadow Element:</a>
    <li><a href="#ref-for-pair①">5.1. Rules for parsing part mappings</a> <a href="#ref-for-pair②">(2)</a> <a href="#ref-for-pair③">(3)</a>
    <li><a href="#ref-for-pair④">5.2. Rules for parsing a list of part mappings</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-string">
   <a href="https://infra.spec.whatwg.org/#string">https://infra.spec.whatwg.org/#string</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-string">2. Exposing a Shadow Element:</a> <a href="#ref-for-string①">(2)</a> <a href="#ref-for-string②">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-hover-pseudo">
   <a href="https://drafts.csswg.org/selectors-4/#hover-pseudo">https://drafts.csswg.org/selectors-4/#hover-pseudo</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-hover-pseudo">1.1. Motivation</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-live-profile">
   <a href="https://drafts.csswg.org/selectors-4/#live-profile">https://drafts.csswg.org/selectors-4/#live-profile</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-live-profile">1.1. Motivation</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-originating-element">
   <a href="https://drafts.csswg.org/selectors-4/#originating-element">https://drafts.csswg.org/selectors-4/#originating-element</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-originating-element">3. Selecting a Shadow Element: the ::part() pseudo-element</a> <a href="#ref-for-originating-element①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-structural-pseudo-classes">
   <a href="https://drafts.csswg.org/selectors-4/#structural-pseudo-classes">https://drafts.csswg.org/selectors-4/#structural-pseudo-classes</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-structural-pseudo-classes">3. Selecting a Shadow Element: the ::part() pseudo-element</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-PutForwards">
   <a href="https://heycam.github.io/webidl/#PutForwards">https://heycam.github.io/webidl/#PutForwards</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-PutForwards">4. Extensions to the Element Interface</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-SameObject">
   <a href="https://heycam.github.io/webidl/#SameObject">https://heycam.github.io/webidl/#SameObject</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-SameObject">4. Extensions to the Element Interface</a>
   </ul>
  </aside>
  <h3 class="no-num no-ref heading settled" id="index-defined-elsewhere"><span class="content">Terms defined by reference</span><a class="self-link" href="#index-defined-elsewhere"></a></h3>
  <ul class="index">
   <li>
    <a data-link-type="biblio">[css-values-4]</a> defines the following terms:
    <ul>
     <li><span class="dfn-paneled" id="term-for-mult-one-plus" style="color:initial">+</span>
     <li><span class="dfn-paneled" id="term-for-typedef-ident" style="color:initial">&lt;ident></span>
    </ul>
   <li>
    <a data-link-type="biblio">[css-variables-1]</a> defines the following terms:
    <ul>
     <li><span class="dfn-paneled" id="term-for-custom-property" style="color:initial">custom property</span>
    </ul>
   <li>
    <a data-link-type="biblio">[DOM]</a> defines the following terms:
    <ul>
     <li><span class="dfn-paneled" id="term-for-domtokenlist" style="color:initial">DOMTokenList</span>
     <li><span class="dfn-paneled" id="term-for-element" style="color:initial">Element</span>
     <li><span class="dfn-paneled" id="term-for-concept-tree-descendant" style="color:initial">descendant</span>
     <li><span class="dfn-paneled" id="term-for-element-shadow-host" style="color:initial">shadow host</span>
     <li><span class="dfn-paneled" id="term-for-concept-shadow-root" style="color:initial">shadow root</span>
     <li><span class="dfn-paneled" id="term-for-concept-shadow-tree" style="color:initial">shadow tree</span>
     <li><span class="dfn-paneled" id="term-for-dom-domtokenlist-value" style="color:initial">value</span>
    </ul>
   <li>
    <a data-link-type="biblio">[INFRA]</a> defines the following terms:
    <ul>
     <li><span class="dfn-paneled" id="term-for-list-append" style="color:initial">append</span>
     <li><span class="dfn-paneled" id="term-for-collect-a-sequence-of-code-points" style="color:initial">collect a sequence of code points</span>
     <li><span class="dfn-paneled" id="term-for-map-exists" style="color:initial">contain</span>
     <li><span class="dfn-paneled" id="term-for-list" style="color:initial">list</span>
     <li><span class="dfn-paneled" id="term-for-ordered-set" style="color:initial">ordered set</span>
     <li><span class="dfn-paneled" id="term-for-pair" style="color:initial">pair</span>
     <li><span class="dfn-paneled" id="term-for-string" style="color:initial">string</span>
    </ul>
   <li>
    <a data-link-type="biblio">[selectors-4]</a> defines the following terms:
    <ul>
     <li><span class="dfn-paneled" id="term-for-hover-pseudo" style="color:initial">:hover</span>
     <li><span class="dfn-paneled" id="term-for-live-profile" style="color:initial">live profile</span>
     <li><span class="dfn-paneled" id="term-for-originating-element" style="color:initial">originating element</span>
     <li><span class="dfn-paneled" id="term-for-structural-pseudo-classes" style="color:initial">structural pseudo-classes</span>
    </ul>
   <li>
    <a data-link-type="biblio">[WebIDL]</a> defines the following terms:
    <ul>
     <li><span class="dfn-paneled" id="term-for-PutForwards" style="color:initial">PutForwards</span>
     <li><span class="dfn-paneled" id="term-for-SameObject" style="color:initial">SameObject</span>
    </ul>
  </ul>
  <h2 class="no-num no-ref heading settled" id="references"><span class="content">References</span><a class="self-link" href="#references"></a></h2>
  <h3 class="no-num no-ref heading settled" id="normative"><span class="content">Normative References</span><a class="self-link" href="#normative"></a></h3>
  <dl>
   <dt id="biblio-css-values-4">[CSS-VALUES-4]
   <dd>Tab Atkins Jr.; Elika Etemad. <a href="https://www.w3.org/TR/css-values-4/">CSS Values and Units Module Level 4</a>. 31 January 2019. WD. URL: <a href="https://www.w3.org/TR/css-values-4/">https://www.w3.org/TR/css-values-4/</a>
   <dt id="biblio-css-variables-1">[CSS-VARIABLES-1]
   <dd>Tab Atkins Jr.. <a href="https://www.w3.org/TR/css-variables-1/">CSS Custom Properties for Cascading Variables Module Level 1</a>. 3 December 2015. CR. URL: <a href="https://www.w3.org/TR/css-variables-1/">https://www.w3.org/TR/css-variables-1/</a>
   <dt id="biblio-dom">[DOM]
   <dd>Anne van Kesteren. <a href="https://dom.spec.whatwg.org/">DOM Standard</a>. Living Standard. URL: <a href="https://dom.spec.whatwg.org/">https://dom.spec.whatwg.org/</a>
   <dt id="biblio-infra">[INFRA]
   <dd>Anne van Kesteren; Domenic Denicola. <a href="https://infra.spec.whatwg.org/">Infra Standard</a>. Living Standard. URL: <a href="https://infra.spec.whatwg.org/">https://infra.spec.whatwg.org/</a>
   <dt id="biblio-rfc2119">[RFC2119]
   <dd>S. Bradner. <a href="https://tools.ietf.org/html/rfc2119">Key words for use in RFCs to Indicate Requirement Levels</a>. March 1997. Best Current Practice. URL: <a href="https://tools.ietf.org/html/rfc2119">https://tools.ietf.org/html/rfc2119</a>
   <dt id="biblio-selectors-4">[SELECTORS-4]
   <dd>Elika Etemad; Tab Atkins Jr.. <a href="https://www.w3.org/TR/selectors-4/">Selectors Level 4</a>. 21 November 2018. WD. URL: <a href="https://www.w3.org/TR/selectors-4/">https://www.w3.org/TR/selectors-4/</a>
   <dt id="biblio-webidl">[WebIDL]
   <dd>Boris Zbarsky. <a href="https://heycam.github.io/webidl/">Web IDL</a>. 15 December 2016. ED. URL: <a href="https://heycam.github.io/webidl/">https://heycam.github.io/webidl/</a>
  </dl>
  <h2 class="no-num no-ref heading settled" id="idl-index"><span class="content">IDL Index</span><a class="self-link" href="#idl-index"></a></h2>
<pre class="idl highlight def"><c- b>partial</c-> <c- b>interface</c-> <a class="idl-code" data-link-type="interface" href="https://dom.spec.whatwg.org/#element" id="ref-for-element①①"><c- g>Element</c-></a> {
  [<a class="idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#SameObject" id="ref-for-SameObject①"><c- g>SameObject</c-></a>, <a class="idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#PutForwards" id="ref-for-PutForwards①"><c- g>PutForwards</c-></a>=<a class="idl-code" data-link-type="attribute" href="https://dom.spec.whatwg.org/#dom-domtokenlist-value" id="ref-for-dom-domtokenlist-value①"><c- n>value</c-></a>] <c- b>readonly</c-> <c- b>attribute</c-> <a class="n" data-link-type="idl-name" href="https://dom.spec.whatwg.org/#domtokenlist" id="ref-for-domtokenlist①"><c- n>DOMTokenList</c-></a> <a data-readonly data-type="DOMTokenList" href="#dom-element-part"><code><c- g>part</c-></code></a>;
};

</pre>
  <h2 class="no-num no-ref heading settled" id="issues-index"><span class="content">Issues Index</span><a class="self-link" href="#issues-index"></a></h2>
  <div style="counter-reset:issue">
   <div class="issue"> Define this as a superglobal in the DOM spec. <a href="https://github.com/w3c/csswg-drafts/issues/3424">&lt;https://github.com/w3c/csswg-drafts/issues/3424></a><a href="#issue-853df044"> ↵ </a></div>
  </div>
  <aside class="dfn-panel" data-for="element-part-name-list">
   <b><a href="#element-part-name-list">#element-part-name-list</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-element-part-name-list">2. Exposing a Shadow Element:</a> <a href="#ref-for-element-part-name-list①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="element-forwarded-part-name-list">
   <b><a href="#element-forwarded-part-name-list">#element-forwarded-part-name-list</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-element-forwarded-part-name-list">2. Exposing a Shadow Element:</a> <a href="#ref-for-element-forwarded-part-name-list①">(2)</a>
    <li><a href="#ref-for-element-forwarded-part-name-list②">2.2. Forwarding a Shadow Element: the exportparts attribute</a> <a href="#ref-for-element-forwarded-part-name-list③">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="shadow-root-part-element-map">
   <b><a href="#shadow-root-part-element-map">#shadow-root-part-element-map</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-shadow-root-part-element-map">1.1. Motivation</a>
    <li><a href="#ref-for-shadow-root-part-element-map①">2. Exposing a Shadow Element:</a> <a href="#ref-for-shadow-root-part-element-map②">(2)</a> <a href="#ref-for-shadow-root-part-element-map③">(3)</a> <a href="#ref-for-shadow-root-part-element-map④">(4)</a> <a href="#ref-for-shadow-root-part-element-map⑤">(5)</a> <a href="#ref-for-shadow-root-part-element-map⑥">(6)</a> <a href="#ref-for-shadow-root-part-element-map⑦">(7)</a>
    <li><a href="#ref-for-shadow-root-part-element-map⑧">3. Selecting a Shadow Element: the ::part() pseudo-element</a> <a href="#ref-for-shadow-root-part-element-map⑨">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="calculate-the-part-element-map">
   <b><a href="#calculate-the-part-element-map">#calculate-the-part-element-map</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-calculate-the-part-element-map">2. Exposing a Shadow Element:</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="element-attrdef-html-global-part">
   <b><a href="#element-attrdef-html-global-part">#element-attrdef-html-global-part</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-element-attrdef-html-global-part">2.1. Naming a Shadow Element: the part attribute</a>
    <li><a href="#ref-for-element-attrdef-html-global-part①">3. Selecting a Shadow Element: the ::part() pseudo-element</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="element-attrdef-html-global-exportparts">
   <b><a href="#element-attrdef-html-global-exportparts">#element-attrdef-html-global-exportparts</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-element-attrdef-html-global-exportparts">2.2. Forwarding a Shadow Element: the exportparts attribute</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="selectordef-part">
   <b><a href="#selectordef-part">#selectordef-part</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-selectordef-part①">1. Introduction</a>
    <li><a href="#ref-for-selectordef-part②">1.1. Motivation</a> <a href="#ref-for-selectordef-part③">(2)</a> <a href="#ref-for-selectordef-part④">(3)</a>
    <li><a href="#ref-for-selectordef-part⑤">3. Selecting a Shadow Element: the ::part() pseudo-element</a> <a href="#ref-for-selectordef-part⑥">(2)</a> <a href="#ref-for-selectordef-part⑦">(3)</a> <a href="#ref-for-selectordef-part⑧">(4)</a> <a href="#ref-for-selectordef-part⑨">(5)</a> <a href="#ref-for-selectordef-part①⓪">(6)</a>
   </ul>
  </aside>
<script>/* script-var-click-highlighting */

    document.addEventListener("click", e=>{
        if(e.target.nodeName == "VAR") {
            highlightSameAlgoVars(e.target);
        }
    });
    {
        const indexCounts = new Map();
        const indexNames = new Map();
        function highlightSameAlgoVars(v) {
            // Find the algorithm container.
            let algoContainer = null;
            let searchEl = v;
            while(algoContainer == null && searchEl != document.body) {
                searchEl = searchEl.parentNode;
                if(searchEl.hasAttribute("data-algorithm")) {
                    algoContainer = searchEl;
                }
            }

            // Not highlighting document-global vars,
            // too likely to be unrelated.
            if(algoContainer == null) return;

            const algoName = algoContainer.getAttribute("data-algorithm");
            const varName = getVarName(v);
            const addClass = !v.classList.contains("selected");
            let highlightClass = null;
            if(addClass) {
                const index = chooseHighlightIndex(algoName, varName);
                indexCounts.get(algoName)[index] += 1;
                indexNames.set(algoName+"///"+varName, index);
                highlightClass = nameFromIndex(index);
            } else {
                const index = previousHighlightIndex(algoName, varName);
                indexCounts.get(algoName)[index] -= 1;
                highlightClass = nameFromIndex(index);
            }

            // Find all same-name vars, and toggle their class appropriately.
            for(const el of algoContainer.querySelectorAll("var")) {
                if(getVarName(el) == varName) {
                    el.classList.toggle("selected", addClass);
                    el.classList.toggle(highlightClass, addClass);
                }
            }
        }
        function getVarName(el) {
            return el.textContent.replace(/(\s| )+/, " ").trim();
        }
        function chooseHighlightIndex(algoName, varName) {
            let indexes = null;
            if(indexCounts.has(algoName)) {
                indexes = indexCounts.get(algoName);
            } else {
                // 7 classes right now
                indexes = [0,0,0,0,0,0,0];
                indexCounts.set(algoName, indexes);
            }

            // If the element was recently unclicked,
            // *and* that color is still unclaimed,
            // give it back the same color.
            const lastIndex = previousHighlightIndex(algoName, varName);
            if(indexes[lastIndex] === 0) return lastIndex;

            // Find the earliest index with the lowest count.
            const minCount = Math.min.apply(null, indexes);
            let index = null;
            for(var i = 0; i < indexes.length; i++) {
                if(indexes[i] == minCount) {
                    return i;
                }
            }
        }
        function previousHighlightIndex(algoName, varName) {
            return indexNames.get(algoName+"///"+varName);
        }
        function nameFromIndex(index) {
            return "selected" + index;
        }
    }
    </script>
<script>/* script-dfn-panel */

document.body.addEventListener("click", function(e) {
    var queryAll = function(sel) { return [].slice.call(document.querySelectorAll(sel)); }
    // Find the dfn element or panel, if any, that was clicked on.
    var el = e.target;
    var target;
    var hitALink = false;
    while(el.parentElement) {
        if(el.tagName == "A") {
            // Clicking on a link in a <dfn> shouldn't summon the panel
            hitALink = true;
        }
        if(el.classList.contains("dfn-paneled")) {
            target = "dfn";
            break;
        }
        if(el.classList.contains("dfn-panel")) {
            target = "dfn-panel";
            break;
        }
        el = el.parentElement;
    }
    if(target != "dfn-panel") {
        // Turn off any currently "on" or "activated" panels.
        queryAll(".dfn-panel.on, .dfn-panel.activated").forEach(function(el){
            el.classList.remove("on");
            el.classList.remove("activated");
        });
    }
    if(target == "dfn" && !hitALink) {
        // open the panel
        var dfnPanel = document.querySelector(".dfn-panel[data-for='" + el.id + "']");
        if(dfnPanel) {
            dfnPanel.classList.add("on");
            var rect = el.getBoundingClientRect();
            dfnPanel.style.left = window.scrollX + rect.right + 5 + "px";
            dfnPanel.style.top = window.scrollY + rect.top + "px";
            var panelRect = dfnPanel.getBoundingClientRect();
            var panelWidth = panelRect.right - panelRect.left;
            if(panelRect.right > document.body.scrollWidth && (rect.left - (panelWidth + 5)) > 0) {
                // Reposition, because the panel is overflowing
                dfnPanel.style.left = window.scrollX + rect.left - (panelWidth + 5) + "px";
            }
        } else {
            console.log("Couldn't find .dfn-panel[data-for='" + el.id + "']");
        }
    } else if(target == "dfn-panel") {
        // Switch it to "activated" state, which pins it.
        el.classList.add("activated");
        el.style.left = null;
        el.style.top = null;
    }

});
</script>